<?php

/**
 * RaiseObject abstract class
 * This is the base class for all phpRaise classes
 *
 * @author Sam-Mauris Yong <hellclanner at live dot com>
 * @license http://www.opensource.org/licenses/bsd-license New BSD License
 * @package Raise.Core
 * @since 1.2
 */
abstract class RaiseObject {

    /**
     * Get the hash code of this object
     * @return string
     */
    public function hashCode(){
        return spl_object_hash($this);
    }

    /**
     * Compare whether both objects are equal or not
     * @param RaiseObject $o
     * @return boolean
     */
    public function equals($o){
        return $this->hashCode() === $o->hashCode();
    }

    /**
     * Dispose all resources and free memory associated with this object
     */
    public function dispose(){
        
    }

    /**
     * Compatibility for OOP before PHP 5 for object cloning
     * @return object
     */
    public function raiseClone(){
        if (version_compare(PHP_VERSION, '5.0.0', '<')){
            return $this;
        }else{
            return clone $this;
        }
    }

    /**
     * RaiseObject is destroyed, do the appropriate disposal
     */
    public function  __destruct() {
        $this->dispose();
    }

}